package com.tuu.vo;

import java.io.Serializable;

public class ResultVO implements Serializable {
    private static final long serialVersionUID = -856924038217431339L;//SysResult/Result/R
    /**状态码*/
    private int state=1;//1表示SUCCESS,0表示ERROR
    /**状态信息*/
    private String message="ok";
    /**正确数据*/
    private Object data;
    public ResultVO() {}
    public ResultVO(String message){
        this.message=message;
    }
    /**一般查询时调用，封装查询结果*/
    public ResultVO(Object data) {
        this.data=data;
    }
    /**出现异常时时调用*/
    public ResultVO(Throwable t){
        this.state=0;
        this.message=t.getMessage();
    }
    public static ResultVO buildError(String message){
        ResultVO vo=new ResultVO();
        vo.setState(0);
        vo.message=message;
        return vo;
    }
    public int getState() {
        return state;
    }
    public void setState(int state) {
        this.state = state;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public Object getData() {
        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }

}
